<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.restaurant.model.User" %>
<html>
<head>
    <title>餐厅收银系统 - 主页</title>
    <style>
        .header { text-align: right; padding: 10px 20px; border-bottom: 1px solid #eee; }
        .welcome { text-align: center; margin: 20px 0; font-size: 24px; color: #333; }
        .menu { width: 80%; margin: 0 auto; display: flex; gap: 20px; flex-wrap: wrap; }
        .menu-item {
            width: 150px; height: 120px; line-height: 120px; text-align: center;
            background: #2f54eb; color: white; border-radius: 8px; cursor: pointer;
            font-size: 16px;
        }
        .menu-item:hover { background: #1d39c4; }
    </style>
</head>
<body>
<div class="header">
    <%
        User loginUser = (User) session.getAttribute("loginUser");
        if (loginUser == null) {
            response.sendRedirect(request.getContextPath() + "/login.jsp");
            return;
        }
    %>
    欢迎您，${loginUser.username}（${loginUser.role}）！
    <a href="${pageContext.request.contextPath}/logout">退出登录</a>
</div>

<div class="welcome">
    <h1>餐厅收银系统</h1>
</div>

<!-- 功能导航栏（按角色显示） -->
<div class="menu">
    <!-- 所有角色可见：点餐、订单、打印 -->
    <div class="menu-item" onclick="location.href='order.jsp'">点餐</div>
    <div class="menu-item" onclick="location.href='order-list.jsp'">订单</div>
    <div class="menu-item" onclick="location.href='print.jsp'">打印</div>

    <!-- 仅管理员可见：会员、报表 -->
    <% if ("admin".equals(loginUser.getRole())) { %>
    <div class="menu-item" onclick="location.href='member.jsp'">会员</div>
    <div class="menu-item" onclick="location.href='report.jsp'">报表</div>
    <% } %>
</div>
</body>
</html>